﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Autofac;

namespace Domain.Services
{
    public class DomainServicesAutofacRegister : Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            var services = Assembly.GetExecutingAssembly()
                         .GetTypes()
                         .Where(t => t.IsClass && !t.IsGenericType && !t.IsAbstract && t.Name.EndsWith("Service"));
            builder.RegisterTypes([.. services]).AsImplementedInterfaces()
                .InstancePerLifetimeScope();
        }
    }
}
